package ink.xiaobaibai.entity;

import com.baomidou.mybatisplus.annotation.*;
import ink.xiaobaibai.valited.UpdateGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Future;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author xiaobaibai
 * @since 2021-08-06
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("coupon_code")
public class CouponCode implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 优惠券码主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 券码名称
     */
    @TableField("name")
    @NotNull
    @NotNull(groups = UpdateGroup.class)
    private String name;

    /**
     * 6位字母前缀
     */
    @TableField("letter_pre")
    @NotNull
    @Length(min = 6, max = 6)
    private String letterPre;

    /**
     * 生成数量(最大8kw)redis一个bitmap的事情
     */
    @TableField("count")
    @NotNull
    @Max(Integer.MAX_VALUE)
    @Min(1)
    private Integer count;

    /**
     * 折扣率
     */
    @TableField("percentage")
    @Min(1)
    @Max(99)
    @Min(value = 1, groups = UpdateGroup.class)
    @Max(value = 99, groups = UpdateGroup.class)
    private Integer percentage;

    /**
     * 失效时间
     */
    @TableField("expires_time")
    @Future
    @Future(groups = UpdateGroup.class)
    private Date expiresTime;

    /**
     * 业务类型 0定点 1包月
     */
    @TableField("type")
    @Min(0)
    @Max(1)
    private Integer type;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;


}
